import React from 'react'
import {Row, Col, Button} from 'antd'
import {Redirect} from 'react-router-dom'
import useStudents from './hooks/useStudents.js'

const layout = {
  xs: {span: 20},
  md: {span: 12, offset: 6}
};

export default ({history, location: {state: {classname}}}) => {
  const {finished} = useStudents(classname)
  if(finished) {
    return (
      <Redirect to="/bedge"/>
    )
  }
  return (
    <Row align="middle" justify="center" type="flex"
         style={{height: '100vh', padding: 10}}>
      <Col {...layout}>
        <Button block type="primary" size="large"
                onClick={() => history.push('/name_to_pic', {classname})}>
          根据名字选头像
        </Button>
        <div style={{height: 30}}/>
        <Button block type="primary" size="large"
                onClick={() => history.push('/pic_to_name', {classname})}>
          根据头像选名字
        </Button>
      </Col>
    </Row>
  )
}
